<?php

use think\migration\Migrator;
use think\migration\db\Column;

class MemberTable extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $this->table('member', ['comment'=>'参赛团队'])
            ->addColumn(Column::integer('team_id')->setComment("团队id"))
            ->addColumn(Column::tinyInteger('role')->setComment("角色:0普通角色，1队长")->setDefault(0)->setNullable())
            ->addColumn(Column::integer('wechat_id')->setComment("微信id")->setNullable())
            ->addColumn(Column::string('name', 200)->setComment("姓名"))
            ->addColumn(Column::integer('image')->setComment("照片")->setNullable())
            ->addColumn(Column::string('sex', 2)->setComment("性别")->setNullable())
            ->addColumn(Column::integer('age')->setComment("年龄")->setNullable())
            ->addColumn(Column::string('tel', 30)->setComment("联系方式")->setNullable())
            ->addColumn(Column::string('card', 30)->setComment("身份证号码")->setNullable())
            ->addColumn(Column::string('unit')->setComment("工作单位")->setNullable())
            ->addColumn(Column::string('province', 20)->setComment("省")->setNullable())
            ->addColumn(Column::string('city', 20)->setComment("市")->setNullable())
            ->addColumn(Column::string('area', 20)->setComment("区")->setNullable())
            ->addColumn(Column::string('address', 100)->setComment("详细地址")->setNullable())
            ->addColumn(Column::string('order_id', 100)->setComment("微信订单id")->setNullable())
            ->addColumn(Column::integer('pay_time')->setComment("支付时间")->setNullable())
            ->addColumn(Column::string('bill', 32)->setComment("我们的订单")->setNullable())
            ->addColumn(Column::tinyInteger('way')->setComment("支付渠道:0免费报名，1微信支付，2支付宝支付，3线下报名")->setDefault(0)->setNullable())
            ->addColumn(Column::json('pay_info')->setComment("支付信息")->setNullable())
            ->addColumn(Column::decimal('amount', 10, 2)->setComment("支付金额")->setDefault(0)->setNullable())
            ->addColumn(Column::tinyInteger('pay_state')->setComment("支付状态")->setDefault(0)->setNullable())
            ->addColumn(Column::integer('status')->setComment("审核状态")->setDefault(0))
            ->addColumn(Column::text('reason')->setComment("退回原因")->setNullable())
            ->addColumn(Column::string('examine1', 5)->setComment("疫情问卷调查")->setNullable()->setDefault('否'))
            ->addColumn(Column::string('examine2', 5)->setComment("疫情问卷调查")->setNullable()->setDefault('否'))
            ->addColumn(Column::string('examine3', 5)->setComment("疫情问卷调查")->setNullable()->setDefault('否'))
            ->addColumn(Column::string('examine4')->setComment("疫情问卷调查")->setNullable()->setDefault('否'))
            ->addColumn(Column::string('accident_insurance')->setComment("意外保险")->setNullable()->setDefault('否'))
            ->addColumn(Column::integer('create_time')->setComment('创建时间')->setNullable())
            ->addColumn(Column::integer('update_time')->setComment('修改时间')->setNullable())
            ->addColumn(Column::integer('delete_time')->setComment('删除时间')->setNullable())
            ->create();
    }
}
